package com.iscas.lndicatormonitor.controller;

import com.iscas.lndicatormonitor.common.CustomResult;
import com.iscas.lndicatormonitor.domain.Audit;
import com.iscas.lndicatormonitor.service.AuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/audit")
public class AuditController {

    @Autowired
    AuditService auditService;
    @GetMapping("/getAllAudit")
    public CustomResult getAll(){
        List<Audit> auditList = auditService.selectAllAudit();
        return new CustomResult(20000,"获取成功",auditList);
    }

    @GetMapping("/delAuditById")
    public  CustomResult delAuditById(int id){
        try{
            auditService.deleteByPrimaryKey(id);
            return new CustomResult(20000,"删除成功",null);
        }catch (Exception e){
            return new CustomResult(40000,"删除失败",null);
        }
    }
}
